#coding:utf8

import pandas as pd
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StringType, IntegerType

# 读取txt文件创建DF
if __name__ == '__main__':
    # 构建SparkSession执行环境入口对象
    spark = SparkSession.builder.\
        appName("test_text").\
        master("local[*]").\
        getOrCreate()

    # 读取text默认只能是String类型,而且只有一列数据
    schema = StructType().add('data', StringType())

    df = spark.read.format("text").\
        schema(schema).load('../data/input/sql/people.txt')

    df.show()